<!--
描述：
开发人：zhaohang
开发日期：2019年10月31日
-->
<template lang="pug">
  kalix-dialog.user-add(title='添加' bizKey="moocClass" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot")
      el-form-item(label="课程名称" prop="className"  v-bind:rules="rules.className")
        el-input(v-model="formModel.className")
      el-form-item(label="课程类别" prop="classType"  v-bind:rules="rules.classType")
        el-input(v-model="formModel.classType")
      el-form-item.short(label="课程封面" prop="classCover")
        kalix-clansman-upload(:action="action" v-on:filePath="getFilePath" fileType="img" tipText="只能上传jpg/png文件")
      el-form-item(label="教师名称" prop="teacher"  v-bind:rules="rules.teacher")
        el-input(v-model="formModel.teacher")
      el-form-item(label="课程简介" prop="classIntroduce"  v-bind:rules="rules.classIntroduce")
        el-input(v-model="formModel.classIntroduce")
      el-form-item(label="教师简介" prop="teacherIntroduce"  v-bind:rules="rules.teacherIntroduce")
        el-input(v-model="formModel.teacherIntroduce")
      el-form-item(label="所属院系" prop="department"  v-bind:rules="rules.department")
        el-input(v-model="formModel.moocSelect")
      el-form-item(label="所属专业" prop="speciality"  v-bind:rules="rules.speciality")
        el-input(v-model="formModel.speciality")
      el-form-item(label="开课时间" prop="openTime"  v-bind:rules="rules.openTime")
        el-input(v-model="formModel.openTime")
      el-form-item(label="是否审核" prop="open"  v-bind:rules="rules.open")
        el-select(v-model="formModel.open"  placeholder="请选择")
          el-option(v-for="item in option" v-bind:key="item.value" v-bind:value="item.value" v-bind:label="item.label")
      el-form-item(label="是否推荐" prop="recommend"  v-bind:rules="rules.recommend")
        el-select(v-model="formModel.recommend"  placeholder="请选择")
          el-option(v-for="item in options" v-bind:key="item.value" v-bind:value="item.value" v-bind:label="item.label")
      el-form-item(label="是否评价" prop="appraise"  v-bind:rules="rules.appraise")
        el-select(v-model="formModel.appraise"  placeholder="请选择")
          el-option(v-for="item in options" v-bind:key="item.value" v-bind:value="item.value" v-bind:label="item.label")
      el-form-item(label="是否收费" prop="charge"  v-bind:rules="rules.charge")
        el-select(v-model="formModel.charge"  placeholder="请选择")
          el-option(v-for="item in options" v-bind:key="item.value" v-bind:value="item.value" v-bind:label="item.label")
</template>

<script type="text/ecmascript-6">
  import {moocClassURL} from '../../config.toml'
  import FormModel from './model'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  export default {
    name: 'MoocClassAdd',
    components: {KalixClansmanUpload},
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        rules: {
          className: [{required: true, message: '请输入课程名称', trigger: 'change'}],
          classCover: [{required: true, message: '请输入classCover', trigger: 'change'}],
          classType: [{required: true, message: '请输入classType', trigger: 'change'}],
          teacher: [{required: true, message: '请输入teacher', trigger: 'change'}],
          classIntroduce: [{required: true, message: '请输入classIntroduce', trigger: 'change'}],
          teacherIntroduce: [{required: true, message: '请输入teacherIntroduce', trigger: 'change'}],
          speciality: [{required: true, message: '请输入speciality', trigger: 'change'}],
          openTime: [{required: true, message: '请输入openTime', trigger: 'change'}],
          isOpen: [{required: true, message: '请输入isOpen', trigger: 'change'}],
          isRecommend: [{required: true, message: '请输入isRecommend', trigger: 'change'}],
          isAppraise: [{required: true, message: '请输入isAppraise', trigger: 'change'}],
          charge: [{required: true, message: '请输入charge', trigger: 'change'}]
        },
        options: [{
          value: 'true',
          label: '是'
        }, {
          value: 'false',
          label: '否'
        }],
        option: [{
          value: 0,
          label: '待审核'
        }, {
          value: 1,
          label: '通过'
        }, {
          value: 2,
          label: '未通过'
        }
        ],
        action: baseURL + '/camel/rest/upload',
        targetURL: moocClassURL,
        items: []
      }
    },
    methods: {
      getMoocClassName(value) {
        console.log('value--------------', value)
        this.items.forEach((item) => {
          if (item.id === value) {
            this.formModel.name = item.name
          }
        })
      },
      getFilePath(filePath, fileName) {
        this.formModel.classCover = filePath
        this.formModel.imgName = fileName
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">

</style>
